import request from "@/util/http";
import qs from "qs";

export default {
  //渲染页面接口
  gain(forms) {
    return request({
      method: "get",
      params: {
        _gp: "admin.category",
        _mt: "queryCategory",
        id: forms.id, //类目ID
        title: forms.title, //类目标题
        level: forms.level, //类目等级
        parentId: forms.parentId, //父类目id
        pageNo: forms.pageNo, //页码
        limit: forms.limit //页码长度
      }
    });
  },
  //新增管理员
  adduser(form) {
    return request({
      method: "post",
      data: qs.stringify({
        _gp: "admin.category",
        _mt: "addCategory",
        title: form.title, //类目标题
        parentId: form.parentId, //类目父节点
        iconUrl: form.iconUrl, //类目图标
        picUrl: form.picUrl, //类目图片
        level: form.level //类目等级
      })
    });
  },
  //删除接口
  cancel(form) {
    return request({
      method: "post",
      data: qs.stringify({
        _gp: "admin.category",
        _mt: "deleteCategory",
        id: form.id
      })
    });
  },
  //编辑角色
  compile(form) {
    return request({
      method: "post",
      data: qs.stringify({
        _gp: "admin.category",
        _mt: "updateCategory",
        title: form.title, //类目标题
        parentId: form.parentId, //类目父节点
        iconUrl: form.iconUrl, //类目图标
        picUrl: form.picUrl, //类目图片
        level: form.level, //类目等级
        id: form.id
      })
    });
  },
  //获取SPU树
  spu() {
    return request({
      method: "get",
      params: {
        _gp: "admin.category",
        _mt: "categorySecondLevelTree"
      }
    });
  }
};
